// 查询数据
async function queryOne(collection, filter) {
    const result = await collection.findOne(filter);
    return result;
}
async function queryMany(collection, filter) {
    const param = {};
    for (let key in filter) {
        param[key] = new RegExp(filter[key], "ig");
    }
    // const result = await collection.find(param).toArray();
    const list = await collection.find(param);
    const listSort = list.sort({ cTime: -1 });
    const res = listSort.toArray();
    const result = await collection.find(param).toArray();
    return result;
}

module.exports = {
    queryOne,
    queryMany,
};
